package org.zfes.snowier.zbss.xzy.router.user.aftersale;
import java.util.Map;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.zfes.snowier.auth.shiro.util.SecurityUtil;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.zbss.xzy.biz.aftersale.model.AfterSale;
import org.zfes.snowier.zbss.xzy.biz.aftersale.service.IAfterSaleService;
@Controller("org.zfes.snowier.zbss.xzy.router.user.aftersale.AfterSaleController") 
@RequestMapping("/api/user/aftersale")
public class AfterSaleController implements BaseController {

	
	@Autowired
	private IAfterSaleService afterSaleService;
	
	
    @RequestMapping(value="/loadAfterSaleDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadAfterSaleDataSet(@RequestBody Map<String,Object> params){
    	params.put("userId",SecurityUtil.getUserId());
	    DataSet dataSet=  afterSaleService.loadAfterSaleDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
    @RequestMapping(value="/createAfterSale", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public  @ResponseBody Object createAfterSale(String content){
		afterSaleService.createAfterSale(
							new AfterSale().setContent(content)
							.setAccount(SecurityUtil.getAccount())
							.setUserId(SecurityUtil.getUserId()));
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
    @RequestMapping(value="/loadAfterSale/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadAfterSale(@PathVariable("id")Long id){
		Optional<AfterSale> ops = afterSaleService.loadAfterSaleById(id);
		return ajaxQuery("afterSale",ops);
    }
	

}